<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>editerTab</title>
    <script>
        YMWL_ROOT_URL = '{$baseroot}';
    </script>
<script type="text/javascript" src="__libs__/jquery/jquery.min.js?v=__lkversion__"></script>
<link href="__libs__/amaze/css/amazeui.min.css?v=__lkversion__" type="text/css" rel="stylesheet" />
<script src="__libs__/amaze/js/amazeui.min.js?v=__lkversion__" type="text/javascript"></script>
<script src="__libs__/layer/layer.js?v=__lkversion__" type="text/javascript"></script>
<script src="__libs__/layui/layui.js?v=__lkversion__" type="text/javascript"></script>
<link href="__libs__/layui/css/layui.css?v=__lkversion__" rel="stylesheet">

<link rel="stylesheet" href="__libs__/myeditor/css/editormd.css?v=__lkversion__" />
</head>
<script src='__libs__/myeditor/editormd.js'></script>
<script src="__libs__/myeditor/lib/marked.min.js?v=__lkversion__"></script>
<script src="__libs__/myeditor/lib/prettify.min.js?v=__lkversion__"></script>
<script src="__libs__/myeditor/lib/raphael.min.js?v=__lkversion__"></script>
<script src="__libs__/myeditor/lib/underscore.min.js?v=__lkversion__"></script>
<script src="__libs__/myeditor/lib/sequence-diagram.min.js?v=__lkversion__"></script>
<script src="__libs__/myeditor/lib/flowchart.min.js?v=__lkversion__"></script>


<style type="text/css">
  *{
    margin: 0;
    padding: 0;
  }
  #tab_title {
      font-size: 13px;
      color: #555555;
      border: 1px solid #e5e3e9;
      border-radius: 8px;
  }
  button.keep {
      width: 66px;
      height: 36px;
      color: #ffffff;
      font-size: 13px;
      background-color: #05202d;
      border-radius: 16px;
  }

  button.reset {
      width: 66px;
      height: 36px;
      color: #555555;
      font-size: 13px;
      background-color: #f7f7f7;
      border-radius: 16px;
      border: 0;
  }
</style>
<body>

     <div style="width: 90%;margin: 10px auto;">
      <p style="font-size: 13px;width: 100%;margin-top: 24px;margin-bottom: 8px;color:#999999">tab名称：</p>
      <input type="text" id="tab_title" class="layui-input" value="{$title}">
    
      <p style="font-size: 13px;width: 100%;margin-top: 20px;margin-bottom: 8px;color:#999999">编辑内容：</p>
      <div id="tab-editormd">
           <textarea class="editormd-markdown-textarea" name="test-editormd-markdown-doc" id="tab_editormd" >{$content}</textarea>
           <textarea class="editormd-html-textarea" name="editorhtml" id="tab_editorhtml"></textarea>     
      </div>

         <div class="layui-form-item" style="margin-top: 24px;text-align: center">
             <button class="layui-btn keep" onclick="gettab()" lay-submit lay-filter=" template">保存</button>
             <button type="reset" onclick="reset()" class="layui-btn layui-btn-primary reset">取消</button>
         </div>
    </div>

 
</body>

<script>

    $(function () {
        testEditor = editormd("tab-editormd", {
            width: "100%",
            height: 260,
            path: '__libs__/myeditor/lib/',
            codeFold: true,
            //syncScrolling : false,
            saveHTMLToTextarea: true,    // 保存 HTML 到 Textarea
            searchReplace: true,
            watch : true,                // 关闭实时预览
            // htmlDecode: "style,script,iframe|on*",            // 开启 HTML 标签解析，为了安全性，默认不开启    
            //toolbar  : false,             //关闭工具栏
            //previewCodeHighlight : false, // 关闭预览 HTML 的代码块高亮，默认开启
            emoji: true,
            taskList: true,
            tocm: true,         // Using [TOCM]
            tex: true,                   // 开启科学公式TeX语言支持，默认关闭
            flowChart: true,             // 开启流程图支持，默认关闭
            sequenceDiagram: true,       // 开启时序/序列图支持，默认关闭,
            //dialogLockScreen : false,   // 设置弹出层对话框不锁屏，全局通用，默认为true
            //dialogShowMask : false,     // 设置弹出层对话框显示透明遮罩层，全局通用，默认为true
            //dialogDraggable : false,    // 设置弹出层对话框不可拖动，全局通用，默认为true
            //dialogMaskOpacity : 0.4,    // 设置透明遮罩层的透明度，全局通用，默认值为0.1
            //dialogMaskBgColor : "#000", // 设置透明遮罩层的背景颜色，全局通用，默认为#fff
            imageUpload: true,
            imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
            imageUploadURL:YMWL_ROOT_URL+"/admin/event/uploadimg",
            onload: function () {
                $('#question').blur();
                $('textarea').blur();
                // console.log('onload', this);
                // this.fullscreen();
                // this.unwatch();
                // this.watch().fullscreen();
                // this.setMarkdown("#PHP");
                // this.width("100%");
                // this.height(480);
                // this.resize("100%", 640);
            }  
        });
    });

    var lock = false;
     function gettab(){
      var title =$("#tab_title").val();
      var content=$("#tab_editorhtml").val();
      var rcontent=$("#tab_editormd").val();
      var id ={$tid};

      if(title && content){
          if (!lock) {
              lock = true;
              $.ajax({
                  url:YMWL_ROOT_URL+'/admin/set/gettab',
                  type:'post',
                  data:{title:title,content:content,content_read:rcontent,tid:id},
                  success:function(res){

                      if(res.code == 0){
                          layer.msg(res.msg,{icon:1,end:function(){
                                  parent.location.reload();
                              }})
                      }else{
                          layer.msg(res.msg,{iocn:2});
                      }
                  }
              });
          }
      }else{
        layer.msg('数据不完整',{iocn:2});
      }

  }

    function reset(){
        parent.layer.closeAll();
    }

</script>
</html>